﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Security.Cryptography;
using System.IO;
using System.Text;

using CE.User;
using CE.Global;
using CE.Database;
using CE.Provider;
using CE.CarInsurance;
using CE.Company;
using CE.Mail;
using CE.InputOut;
using CE.Image;

public partial class car_insurance_email_this : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session[General.UserId] != null && Session[General.CarId] != null && Session[General.UserName] != null && Session[General.CarResultId] != null)
        {
            if (Cache["CarResult" + Session[General.UserId].ToString() + Session[General.CarId].ToString()] == null)
            { 
                Response.Redirect("login.aspx"); 
            }
        }
        else
        {
            Response.Redirect("login.aspx");
        }


        //  if (Session["ImageCount"] != null)
        //{
        //    if (Convert.ToInt32(Session["ImageCount"].ToString()) > 5)
        //    {
        //        lblMessage.Text = "Please try after a few moment! You are session has been locked!";
        //        btnEmailThis.Enabled = false;
        //        btnNewImage.Enabled = false;
        //        txtEmail.Enabled = false;
        //        txtSecurityCode.Enabled = false;
        //        //Response.Redirect("usermessage.aspx?mt=um&ec=1993");
        //    }
        //    else
        //    {
        //        lblMessage.Text = "";
        //        btnEmailThis.Enabled = true;
        //        btnNewImage.Enabled = true;
        //        txtEmail.Enabled = true;
        //        txtSecurityCode.Enabled = true;
        //    }
        //} 


        if (!Page.IsPostBack)
        {
            txtFullName.Text = Session[General.UserName].ToString();
            txtEmail.Text = Session[General.UserEmail].ToString();

            //if (Session["ImageCount"] != null)
            //{
            //    if (Convert.ToInt32(Session["ImageCount"].ToString()) <= 5)
            //    {
            //        CreateUpdateImageAndSession();
            //    }
            //}
            //else
            //{
            //    CreateUpdateImageAndSession();
            //}
        }

    }

    protected void btnEmailThis_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            //if (Session[CE.Global.General.SecurityCheckWord] != null)
            //{
            //    string _usrText = txtSecurityCode.Text.ToUpper();
            //    string _imgText = Session[CE.Global.General.SecurityCheckWord].ToString().ToUpper();

            //    if (_usrText == _imgText)
            //    {
            if (SendMailToFriend())
            {
                string _providerID = Session[CE.Global.General.ProviderCompanyId].ToString();
                string _ec = "";

                if (_providerID == "23")
                {
                    _ec = "1223";
                }
                else if (_providerID == "29")
                {
                    _ec = "1229";
                }
                else if (_providerID == "30")
                {
                    _ec = "1230";
                }

                CarUserOptionLog();

                //Response.Redirect("~/user/usermessage.aspx?mt=CI&ec=" + _ec);
                Response.Redirect("email-usermessage.aspx");

            }
            //    }
            //    else
            //    {
            //        lblMessage.Text = "Wrong security check!";
            //        CreateUpdateImageAndSession();
            //    }
            //}
            //else
            //{
            //    lblMessage.Text = "Security Check code was expired. Please try again.";
            //    CreateUpdateImageAndSession();
            //}

        }

    }

    //protected void btnNewImage_Click(object sender, EventArgs e)
    //{
    //    CreateUpdateImageAndSession();
    //}

    protected void btnBack_Click(object sender, EventArgs e)
    {
        //if (Session["FromSummary"] != null)
        //{
        //    if (Session["FromSummary"].ToString().Trim() == "1")
        //    {
        //        Response.Redirect("results-new.aspx");
        //    }
        //    else
        //    {
        //        Response.Redirect("results-details.aspx");
        //    }
        //}
        //else
        //{
        //    Response.Redirect("results-new.aspx");
        //}

        Response.Redirect("results.aspx");
    }

    //private void CreateUpdateImageAndSession()
    //{
    //    MyImage myimage = new MyImage();
    //    string salt = "";

    //    if (Session[CE.Global.General.SecurityCheckWord] != null)
    //    {
    //        salt = myimage.GetRandomWord(Session[CE.Global.General.SecurityCheckWord].ToString());
    //    }
    //    else
    //    {
    //        if (Session[CE.Global.General.SecurityCheckWord] != null)
    //        {
    //            salt = myimage.GetRandomWord(Session[CE.Global.General.SecurityCheckWord].ToString());
    //        }
    //        else
    //        {
    //            salt = myimage.GetRandomWord("all");
    //        }
    //    }

    //    Session[CE.Global.General.SecurityCheckWord] = salt;       
    //    imgCAPTCHA.ImageUrl = @"~/CAPTCHA/CAPTCHAImageHandler.ashx?id=" + CE.Security.MySecurity.Encrypt(salt, true);
    //    txtSecurityCode.Text = "";
    //}

    private bool SendMailToFriend()
    {
        CE.User.Profile usrprofile = new Profile();
        ProfileDB usrprofiledb = new ProfileDB();

        usrprofile = usrprofiledb.GetProfile(Convert.ToInt64(Session[General.UserId].ToString()));

        string userfirstname = "";

        if (usrprofile != null)
        {
            userfirstname = usrprofile.FirstName;
        }

        bool _retVal = false;
        string _strCXLive = CE.Configuration.MyConfigurationManager.GetAppSettingValue("IsCXLive");

        string _emailTo = txtEmailTo.Text.Trim();
        string _customername = Session[General.UserName].ToString();
        //string _emailSubject = txtEmailTo.Text.Trim() + " Car Insurance Quotes on CompareXpress";
        string _emailSubject = "Car Insurance Quotes on CompareXpress";
        string _mailBody = "";
        string _currentDomainUrl = "http://" + HttpContext.Current.Request.Url.Host.ToString();
        string imgLogoUrl = _currentDomainUrl + CE.Configuration.MyConfigurationManager.GetAppSettingValue("LogoPath");

        _mailBody = "<body class='email_body'>";
        _mailBody += "<style type='text/css'>";
        _mailBody += ".email_body {background:white;margin:0; padding:0; color:#4c4c4c; font-family:Arial, Helvetica, sans-serif; font-size:0.85em;}";
        _mailBody += "a {text-decoration:underline;color:#2c95cc;} ";
        _mailBody += "#email_container {margin:0 auto;padding:20px;width:600px; height:auto;} ";
        _mailBody += "#email_body {width:100%; text-align: left !important;} ";
        _mailBody += ".email_pad10px {padding:10px;} ";
        _mailBody += ".email_results td {width:33%;} ";
        _mailBody += "</style>";
        _mailBody += "<center>";

        _mailBody += "<table cellpadding='0' cellspacing='0' border='0' style='padding:20px;' width='600'>";
        _mailBody += "<tr><td width='360'><a href='http://www.comparexpress.com/car-insurance/login.aspx' target='_blank'><img src='" + _currentDomainUrl + "/images/email/header_quote_plain.png' width='596' height='187' alt='CompareXpress' border='0' /></a></td></tr>";
        _mailBody += "<tr><td style='padding-left:45px; padding-right:45px;'><strong>Dear " + txtFriendName.Text.Trim() + ",</strong><br/><br/>";
        //_mailBody += "The car insurance quotes below was sent to you by " + Session[General.UserName].ToString() + ",<br/>";
        _mailBody += "The car insurance quotes below was sent to you by " + userfirstname + ",<br/>";
        _mailBody += Session[General.UserEmail].ToString() + ".<br/><br/>";

        DataView dvResults = new DataView((DataTable)Cache["CarResult" + Session[General.UserId].ToString() + Session[General.CarId].ToString()]);

        _mailBody += "<table cellpadding='5' cellspacing='0' border='0' width='546px' class='table_details'>";

        string CITempResultId = Session[CE.Global.General.CarResultId].ToString();
        dvResults.RowFilter = " CITempResultId in (" + CITempResultId + ")";

        DataTable dtResults = dvResults.ToTable();


        if (dtResults.Rows.Count > 0)
        {
            string _providercompanyid = dtResults.Rows[0]["providercompanyid"].ToString();
            //logo
            string logourl = "/images/public/logo/";
            if (_providercompanyid == "23")
            {
                logourl += "hsbc.png";
            }
            else if (_providercompanyid == "29")
            {
                logourl += "liberty.png";
            }
            else if (_providercompanyid == "30")
            {
                logourl += "etiqa.png";
            }

            _mailBody += "<tr>";
            _mailBody += "<td width='45%'></td>";
            _mailBody += "<td width='55%' align='center' style='background:#e0e0e0; border-bottom:white 1px dashed;'><img src='" + _currentDomainUrl + logourl + "' width='130' style='padding:3px;' border='0'/></td>";
            _mailBody += "</tr>";

            string insurername = dtResults.Rows[0]["InsurerName"].ToString();

            if (dtResults.Rows[0]["providercompanyid"].ToString() == "23" || dtResults.Rows[0]["providercompanyid"].ToString() == "30")
            {
                insurername = insurername + " Insurance";
            }

            //insurer name
            _mailBody += "<tr>";
            _mailBody += "<td><strong>Insurer</strong></td>";
            _mailBody += "<td align='center' style='background:#d5d5d5; color:white;'><strong>" + insurername + "</strong></td>";
            _mailBody += "</tr>";

            //premium
            _mailBody += "<tr>";
            _mailBody += "<td align='left' style='background:#d5d5d5' ><strong>Price</strong></td>";
            _mailBody += "<td align='center' style='background:#c5c5c5; color:black; font-size:20px;'><strong>" + String.Format("${0:0,0.00}", Convert.ToSingle(dtResults.Rows[0]["annualpremium"].ToString())) + "</strong></td>";
            _mailBody += "</tr>";

            float _fMonthlyPremiumAmount = Convert.ToSingle(dtResults.Rows[0]["MonthlyPremiumAmount"].ToString());
            string monthlyInstallment = "";

            if (_fMonthlyPremiumAmount > 0.0f)
            {
                string _monthlyPremiumAmount = String.Format("${0:0,0.00}", _fMonthlyPremiumAmount);

                monthlyInstallment = _monthlyPremiumAmount + "/mth<br/>";

                if (_providercompanyid == "29")
                {
                    monthlyInstallment += "<br/># Citi card only";
                }
                else if (_providercompanyid == "23")
                {
                    monthlyInstallment += "<br/># HSBC or OCBC card only";
                }

            }
            else
            {
                monthlyInstallment = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }

            //installment
            _mailBody += "<tr>";
            _mailBody += "<td><strong>Monthly Installments <br/>12-mth 0% Interest Free</strong></td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + monthlyInstallment + "</td>";
            _mailBody += "</tr>";

            //Excess (named drivers) 
            _mailBody += "<tr>";
            _mailBody += "<td style='border-bottom:1px solid #ccc;'><strong>Excess </strong> (named drivers)</td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + String.Format("${0:0,0.00}", Convert.ToSingle(dtResults.Rows[0]["excess"].ToString())) + "</td>";
            _mailBody += "</tr>";

            //Workshop Plan
            _mailBody += "<tr>";
            _mailBody += "<td><strong>Workshop Plan</strong></td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + dtResults.Rows[0]["PlanName"].ToString() + "</td>";
            _mailBody += "</tr>";

            //Personal Accident
            _mailBody += "<tr>";
            _mailBody += "<td><strong>Personal Accident</strong> (insured) </td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + String.Format("${0:#,0}", Convert.ToSingle(dtResults.Rows[0]["PolicyHolder"].ToString())) + "</td>";
            _mailBody += "</tr>";

            //Personal Accident (each passenger)
            _mailBody += "<tr>";
            _mailBody += "<td style='border-bottom:1px solid #ccc;'><strong>Personal Accident</strong> (each passenger) </td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + String.Format("${0:#,0}", Convert.ToSingle(dtResults.Rows[0]["PassengerEach"].ToString())) + "</td>";
            _mailBody += "</tr>";

            int _MedicalExpense = Convert.ToInt32(dtResults.Rows[0]["MedicalExpense"].ToString());
            string medicalExpense = "";

            if (_MedicalExpense == 0)
            {
                medicalExpense = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }
            else
            {
                medicalExpense = String.Format("${0:#,0}", Convert.ToSingle(_MedicalExpense.ToString()));
            }

            //Medical Expense
            _mailBody += "<tr>";
            _mailBody += "<td><strong>Medical Expense</strong> (each passenger) </td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + medicalExpense + "</td>";
            _mailBody += "</tr>";

            bool _IsPersonnalEffectsLoss = Convert.ToBoolean(dtResults.Rows[0]["IsPersonnalEffectsLoss"].ToString());
            int _LossPE = Convert.ToInt32(dtResults.Rows[0]["PersonnalEffectsLoss"].ToString());
            string lossPE = "";

            if (!_IsPersonnalEffectsLoss)
            {
                lossPE = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
            }
            else
            {
                lossPE = String.Format("${0:#,0}", Convert.ToSingle(_LossPE.ToString()));
            }

            //Loss of Personal Effects
            _mailBody += "<tr>";
            _mailBody += "<td><strong>Loss of Personal Effects</strong></td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + lossPE + "</td>";
            _mailBody += "</tr>";

            string _CarReplace = dtResults.Rows[0]["CarReplacement"].ToString();
            bool _IsCarReplace = Convert.ToBoolean(dtResults.Rows[0]["IsCarReplacement"].ToString());
            bool _IsTranspoAllowance = Convert.ToBoolean(dtResults.Rows[0]["isCashAllowance"].ToString());
            string _strTranspoAllowance = Convert.ToString(dtResults.Rows[0]["CashAllowance"].ToString());
            string _strMaxTranspoAllowanceDays = Convert.ToString(dtResults.Rows[0]["MaxCashAllowanceDays"].ToString());
            string lossUse = "";

            if (_IsCarReplace)
            {
                lossUse = "Courtesy Car <br/>" + "max " + _CarReplace.ToString() + " day(s)";
            }
            else
            {
                if (_IsTranspoAllowance)
                {
                    lossUse = "Transport Allowance<br/> S$" + _strTranspoAllowance + "/day <br/> max " + _strMaxTranspoAllowanceDays + " day(s)";
                }
                else
                {
                    lossUse = "<img src='" + _currentDomainUrl + "/images/icon/X.png' width='16' alt='NA' />";
                }

            }

            //Loss of Use (Benefit) 
            _mailBody += "<tr>";
            _mailBody += "<td><strong>Loss of Use</strong> (Benefit)</td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + lossUse + "</td>";
            _mailBody += "</tr>";


            string viewworkshops = "";

            if (_providercompanyid == "29")
            {
                viewworkshops = "<a href='http://www.libertyinsurance.com.sg/pdf/PWS%20Nov05.pdf' target='_blank'><img src='" + _currentDomainUrl + "/images/icon/pdf.png' alt='workshops' width='23' alt='NA' border='0'/></a>";
            }
            else if (_providercompanyid == "30")
            {
                viewworkshops = "<a href='" + _currentDomainUrl + "/policy_docs/Etiqa/Etiqa - AWS Listing.pdf' target='_blank'><img src='" + _currentDomainUrl + "/images/icon/pdf.png' alt='workshops' width='23' alt='NA' border='0' /></a>";
            }
            else
            {
                viewworkshops = "<a href='" + _currentDomainUrl + "/policy_docs/HSBC/HSBCworkshops.pdf' target='_blank'><img src='" + _currentDomainUrl + "/images/icon/pdf.png' alt='workshops' width='23' alt='NA' border='0'/></a>";
            }

            //View Workshops
            _mailBody += "<tr>";
            _mailBody += "<td style='border-bottom:1px solid #ccc;'><strong>View Workshops</strong></td>";
            _mailBody += "<td align='center' style='background:#d5d5d5' >" + viewworkshops + "</td>";
            _mailBody += "</tr>";


            string _policyId = dtResults.Rows[0]["NInfo1"].ToString();

            ProviderPolicyDocument _policydoc = new ProviderPolicyDocument();
            ProviderPolicyDocumentDB _policydocdb = new ProviderPolicyDocumentDB();

            _policydoc = _policydocdb.GetProviderPolicyDocument(Convert.ToInt64(_policyId));

            string docurl = _currentDomainUrl + _policydoc.UploadPath.Remove(0, 1);
            string viewpolicywordings = "<a href='" + docurl + "' ><img src='" + _currentDomainUrl + "/images/icon/pdf.png'  alt='policy wordings' width='23' alt='NA' border='0' /></a>";

            //View Policy Wordings
            _mailBody += "<tr>";
            _mailBody += "<td><strong>View Policy Wordings</strong></td>";
            _mailBody += "<td align='center' style='background:#c5c5c5' >" + viewpolicywordings + "</td>";
            _mailBody += "</tr>";

            if (_providercompanyid == "23")
            {
                string endorsementlink = "";

                int _coverid = Convert.ToInt32(dtResults.Rows[0]["CXCoverTypeId"].ToString());

                if (_coverid == 2 || _coverid == 6) //classic
                {
                    endorsementlink = _currentDomainUrl + "/policy_docs/HSBC/PCIClassicPlan.pdf";
                }
                else
                {
                    endorsementlink = _currentDomainUrl + "/policy_docs/HSBC/PCIPremierPlan.pdf";
                }


                string viewendorsements = "<a href='" + endorsementlink + "' target='_blank' id='lnkendorse'><img src='" + _currentDomainUrl + "/images/icon/pdf.png' width='23' alt='NA' border='0' /></a>";

                //View Policy Endorsements
                _mailBody += "<tr>";
                _mailBody += "<td style='border-bottom:1px solid #ccc;'><strong>View Endorsements</strong></td>";
                _mailBody += "<td align='center' style='background:#d5d5d5' >" + viewendorsements + "</td>";
                _mailBody += "</tr>";
            }

        }

        _mailBody += "</table>";    

        _mailBody += "<hr />";
        _mailBody += "This Quote is subject to the insurer's final confirmation and coverage is only effective when the <br/>";
        _mailBody += "insurer has accepted the risk.<br/>";
        _mailBody += "<br /><i>This is a computer-generated email. Please do not reply to this email.</i>";
        _mailBody += "<hr />";
        _mailBody += "</center></body>";

        if (MyMailManager.SendCARMessage(_emailTo, _emailSubject, _mailBody))
        {
            _retVal = true;
        }
        else
        {
            _retVal = false;
        }

        return _retVal;
    }

    #region oldcopy
    //private bool SendMailToFriend()
    //{
    //    CE.User.Profile usrprofile = new Profile();
    //    ProfileDB usrprofiledb = new ProfileDB();

    //    usrprofile = usrprofiledb.GetProfile(Convert.ToInt64(Session[General.UserId].ToString()));

    //    string userfirstname = "";

    //    if (usrprofile != null)
    //    {
    //        userfirstname = usrprofile.FirstName;
    //    }

    //    bool _retVal = false;
    //    string _strCXLive = CE.Configuration.MyConfigurationManager.GetAppSettingValue("IsCXLive");

    //    string _emailTo = txtEmailTo.Text.Trim();
    //    string _customername = Session[General.UserName].ToString();
    //    //string _emailSubject = txtEmailTo.Text.Trim() + " Car Insurance Quotes on CompareXpress";
    //    string _emailSubject = "Car Insurance Quotes on CompareXpress";
    //    string _mailBody = "";
    //    string _currentDomainUrl = "http://" + HttpContext.Current.Request.Url.Host.ToString();
    //    string imgLogoUrl = _currentDomainUrl + CE.Configuration.MyConfigurationManager.GetAppSettingValue("LogoPath");

    //    _mailBody = "<body class='email_body'>";
    //    _mailBody += "<style type='text/css'>";
    //    _mailBody += ".email_body {background:white;margin:0; padding:0; color:#4c4c4c; font-family:Arial, Helvetica, sans-serif; font-size:0.85em;}";
    //    _mailBody += "a {text-decoration:underline;color:#2c95cc;} ";
    //    _mailBody += "#email_container {margin:0 auto;padding:20px;width:600px; height:auto;} ";
    //    _mailBody += "#email_body {width:100%; text-align: left !important;} ";
    //    _mailBody += ".email_pad10px {padding:10px;} ";
    //    _mailBody += ".email_results td {width:33%;} ";
    //    _mailBody += "</style>";
    //    _mailBody += "<center>";

    //    _mailBody += "<table cellpadding='0' cellspacing='0' border='0' style='padding:20px;' width='600'>";
    //    _mailBody += "<tr><td width='360'><a href='http://www.comparexpress.com/car-insurance/login.aspx' target='_blank'><img src='" + _currentDomainUrl + "/images/email/header_quote_plain.png' width='596' height='187' alt='CompareXpress' border='0' /></a></td></tr>";
    //    _mailBody += "<tr><td style='padding-left:45px; padding-right:45px;'><strong>Dear " + txtFriendName.Text.Trim() + ",</strong><br/><br/>";
    //    //_mailBody += "The car insurance quotes below was sent to you by " + Session[General.UserName].ToString() + ",<br/>";
    //    _mailBody += "The car insurance quotes below was sent to you by " + userfirstname + ",<br/>";
    //    _mailBody += Session[General.UserEmail].ToString() + ".<br/><br/>";

    //    DataView dvResults = new DataView((DataTable)Cache["CarResult" + Session[General.UserId].ToString() + Session[General.CarId].ToString()]);

    //    _mailBody += "<table cellpadding='0' cellspacing='0' border='0' width='100%'>";

    //    bool isAlternate = false;

    //    if (Session["FromSummary"] != null)
    //    {
    //        if (Session["FromSummary"].ToString().Trim() == "0") //filter
    //        {
    //            string CITempResultId = Session["CarSelected"].ToString();
    //            dvResults.RowFilter = " CITempResultId in (" + CITempResultId.Remove(CITempResultId.Length - 1, 1) + ")";
    //        }
    //    }

    //    DataTable dtResults = dvResults.ToTable();


    //    for (int irow = 0; irow < dtResults.Rows.Count; irow++)
    //    {
    //        string insurername = dtResults.Rows[irow]["InsurerName"].ToString();

    //        if (dtResults.Rows[irow]["providercompanyid"].ToString() == "23" || dtResults.Rows[irow]["providercompanyid"].ToString() == "30")
    //        {
    //            insurername = insurername + " Insurance";
    //        }

    //        string premium = String.Format("${0:0,0.00}", Convert.ToSingle(dtResults.Rows[irow]["annualpremium"].ToString()));

    //        if (!isAlternate)
    //        {
    //            _mailBody += "<tr style='background:#ededed;'>";
    //            _mailBody += "<td style='padding:10px; color:black' align='left'>" + insurername + "</td>";
    //            _mailBody += "<td style='padding:10px; color:#2d8aba' align='center'> Annual Premium <strong>" + premium + "</strong></td>";
    //            _mailBody += "<td style='padding:10px;' align='right'><a href='http://www.comparexpress.com/car-insurance/login.aspx' ><img src='" + _currentDomainUrl + "/images/email/button_more-details.gif' width='114' height='21' alt='Learn More' border='0' /></a></td>";
    //            _mailBody += "</tr>";

    //            isAlternate = true;
    //        }
    //        else
    //        {
    //            _mailBody += "<tr>";
    //            _mailBody += "<td style='padding:10px; color:black' align='left'>" + insurername + "</td>";
    //            _mailBody += "<td style='padding:10px; color:#2d8aba' align='center'> Annual Premium <strong>" + premium + "</strong></td>";
    //            _mailBody += "<td style='padding:10px;' align='right'><a href='http://www.comparexpress.com/car-insurance/login.aspx'><img src='" + _currentDomainUrl + "/images/email/button_more-details.gif' width='114' height='21' alt='Learn More' border='0'/></a></td>";
    //            _mailBody += "</tr>";

    //            isAlternate = false; ;
    //        }

    //    }

    //    _mailBody += "</table>";

    //    _mailBody += "<br/></td></tr>";
    //    _mailBody += "<tr><td id='email_footer'><a href='http://www.comparexpress.com' target='_blank'><img src='" + _currentDomainUrl + "/images/email/footer_quote.png' alt='CompareXpress - Partners' width='596' height='174' border='0' /></a>";
    //    _mailBody += "</td></tr></table>";

    //    _mailBody += "<hr />";
    //    _mailBody += "This Quote is subject to the insurer's final confirmation and coverage is only effective when the <br/>";
    //    _mailBody += "insurer has accepted the risk.<br/>";
    //    _mailBody += "<br /><i>This is a computer-generated email. Please do not reply to this email.</i>";
    //    _mailBody += "<hr />";
    //    _mailBody += "</center></body>";

    //    if (MyMailManager.SendCARMessage(_emailTo, _emailSubject, _mailBody))
    //    {
    //        _retVal = true;
    //    }
    //    else
    //    {
    //        _retVal = false;
    //    }

    //    return _retVal;
    //}
    #endregion

    private void CarUserOptionLog()
    {
        CarUserOption caruseroption = new CarUserOption();
        CarUserOptionDB caruseroptiondb = new CarUserOptionDB();

        caruseroption.CarUserOptionId = 0;
        caruseroption.CECarId = Convert.ToInt64(Session[General.CarId].ToString());
        caruseroption.IsBuyNow = false;
        caruseroption.IsCallMe = false;
        caruseroption.IsEmailMe = false;
        caruseroption.IsEmailThis = true;
        caruseroption.RecipientName = General.ClearScriptTag(txtFriendName.Text.Trim());
        caruseroption.RecipientEmailAddress = txtEmailTo.Text.Trim();
        caruseroption.ViewedDetailId = 0;
        caruseroption.RefCEUserId = Convert.ToInt64(Session[General.UserId].ToString());

        caruseroptiondb.Insert(caruseroption);
    }

}
